from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
# 1.导入等待类
from selenium.webdriver.support.wait import WebDriverWait
driver = webdriver.Firefox()
driver.maximize_window()
# 设置隐式等待，针对于所有的元素
driver.implicitly_wait(20)
driver.get('file:///D:/nsd2404/html/registerA.html')
# username = driver.find_element(By.CSS_SELECTOR, '#user')
# username.send_keys('admin')
# 2.创建等待对象
wait = WebDriverWait(driver, timeout=20, poll_frequency=0.5)
# 3.显示等待针对于特定某个元素
username = wait.until(lambda x: x.find_element(By.CSS_SELECTOR, '#user'))
username.send_keys('admin')

sleep(3)
driver.quit()